/*
 * Created by JFormDesigner on Mon Jul 05 21:15:09 CST 2021
 */

package com.tarena.view;

import com.tarena.service.UersClientService;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

/**
 * @author unknown
 */
public class ChatLoginWindow extends JFrame {
    private UersClientService ucs;
    public ChatLoginWindow() {
        super("欢迎登录");
        initComponents();
        ucs = new UersClientService(this);
    }

    private void button1MouseClicked(MouseEvent e) {
        String uesrname=textField1.getText();
        String password = textField2.getText();
        /*System.out.println("uesrname:"+uesrname);
        System.out.println("password:"+password);*/
        /*了解服务器并发送uesrname和password进行校验*/
        ucs.UserLogin(uesrname,password);
    }

    public void setLoginFailMessage(String msg){
        label7.setText(msg);
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        // Generated using JFormDesigner Evaluation license - unknown
        panel1 = new JPanel();
        panel5 = new JPanel();
        label1 = new JLabel();
        label2 = new JLabel();
        label3 = new JLabel();
        panel2 = new JPanel();
        panel3 = new JPanel();
        panel4 = new JPanel();
        label5 = new JLabel();
        label6 = new JLabel();
        button2 = new JButton();
        button1 = new JButton();
        panel6 = new JPanel();
        label4 = new JLabel();
        textField1 = new JTextField();
        textField2 = new JTextField();
        label7 = new JLabel();

        //======== this ========
        setBackground(new Color(51, 204, 255));
        setMinimumSize(new Dimension(160, 39));
        Container contentPane = getContentPane();
        contentPane.setLayout(new BorderLayout());

        //======== panel1 ========
        {
            panel1.setBorder (new javax. swing. border. CompoundBorder( new javax .swing .border .TitledBorder (new javax.
            swing. border. EmptyBorder( 0, 0, 0, 0) , "JFor\u006dDesi\u0067ner \u0045valu\u0061tion", javax. swing. border
            . TitledBorder. CENTER, javax. swing. border. TitledBorder. BOTTOM, new Font ("Dia\u006cog"
            , Font .BOLD ,12 ), Color. red) ,panel1. getBorder
            ( )) ); panel1. addPropertyChangeListener (new java. beans. PropertyChangeListener( ){ @Override public void propertyChange (java
            .beans .PropertyChangeEvent e) {if ("bord\u0065r" .equals (e .getPropertyName () )) throw new RuntimeException
            ( ); }} );
            panel1.setLayout(new GridLayout());

            //======== panel5 ========
            {
                panel5.setMinimumSize(new Dimension(84, 144));
                panel5.setPreferredSize(new Dimension(84, 144));
                panel5.setBackground(new Color(242, 242, 242, 242));
                panel5.setLayout(new GridLayout(6, 0));
                panel5.add(label1);

                //---- label2 ----
                label2.setText("\u7528\u6237\u540d");
                label2.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", label2.getFont().getStyle() | Font.BOLD, label2.getFont().getSize() + 6));
                label2.setHorizontalAlignment(SwingConstants.CENTER);
                panel5.add(label2);

                //---- label3 ----
                label3.setText("\u5bc6\u7801");
                label3.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", label3.getFont().getStyle() | Font.BOLD, label3.getFont().getSize() + 6));
                label3.setHorizontalAlignment(SwingConstants.CENTER);
                panel5.add(label3);
            }
            panel1.add(panel5);
        }
        contentPane.add(panel1, BorderLayout.WEST);

        //======== panel2 ========
        {
            panel2.setLayout(new GridLayout());
        }
        contentPane.add(panel2, BorderLayout.NORTH);

        //======== panel3 ========
        {
            panel3.setMinimumSize(new Dimension(54, 0));
            panel3.setPreferredSize(new Dimension(54, 0));
            panel3.setBackground(new Color(242, 242, 242, 242));
            panel3.setLayout(new GridLayout());
        }
        contentPane.add(panel3, BorderLayout.EAST);

        //======== panel4 ========
        {
            panel4.setMinimumSize(new Dimension(312, 40));
            panel4.setLayout(new GridLayout());
            panel4.add(label5);
            panel4.add(label6);

            //---- button2 ----
            button2.setText("\u53d6\u6d88");
            button2.setMinimumSize(new Dimension(78, 40));
            button2.setMaximumSize(new Dimension(78, 40));
            button2.setPreferredSize(new Dimension(78, 40));
            button2.setFont(button2.getFont().deriveFont(button2.getFont().getSize() + 4f));
            panel4.add(button2);

            //---- button1 ----
            button1.setText("\u786e\u5b9a");
            button1.setMaximumSize(new Dimension(78, 40));
            button1.setMinimumSize(new Dimension(78, 40));
            button1.setPreferredSize(new Dimension(78, 40));
            button1.setFont(button1.getFont().deriveFont(button1.getFont().getSize() + 4f));
            button1.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    button1MouseClicked(e);
                }
            });
            panel4.add(button1);
        }
        contentPane.add(panel4, BorderLayout.SOUTH);

        //======== panel6 ========
        {
            panel6.setBackground(new Color(242, 242, 242, 242));
            panel6.setLayout(new GridLayout(6, 0));

            //---- label4 ----
            label4.setMaximumSize(new Dimension(100, 30));
            label4.setMinimumSize(new Dimension(100, 30));
            label4.setPreferredSize(new Dimension(100, 30));
            label4.setText("\u6211\u8981\u767b\u5f55\u5566");
            label4.setHorizontalAlignment(SwingConstants.CENTER);
            label4.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.BOLD, 20));
            panel6.add(label4);

            //---- textField1 ----
            textField1.setMinimumSize(new Dimension(100, 30));
            textField1.setPreferredSize(new Dimension(100, 30));
            textField1.setFont(textField1.getFont().deriveFont(textField1.getFont().getSize() + 6f));
            panel6.add(textField1);

            //---- textField2 ----
            textField2.setMinimumSize(new Dimension(400, 50));
            textField2.setPreferredSize(new Dimension(400, 50));
            textField2.setFont(textField2.getFont().deriveFont(textField2.getFont().getSize() + 6f));
            panel6.add(textField2);

            //---- label7 ----
            label7.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 16));
            label7.setMaximumSize(new Dimension(100, 22));
            label7.setMinimumSize(new Dimension(100, 22));
            label7.setPreferredSize(new Dimension(100, 22));
            label7.setHorizontalAlignment(SwingConstants.CENTER);
            panel6.add(label7);
        }
        contentPane.add(panel6, BorderLayout.CENTER);
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    // Generated using JFormDesigner Evaluation license - unknown
    private JPanel panel1;
    private JPanel panel5;
    private JLabel label1;
    private JLabel label2;
    private JLabel label3;
    private JPanel panel2;
    private JPanel panel3;
    private JPanel panel4;
    private JLabel label5;
    private JLabel label6;
    private JButton button2;
    private JButton button1;
    private JPanel panel6;
    private JLabel label4;
    private JTextField textField1;
    private JTextField textField2;
    private JLabel label7;

    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
